package com.admins.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author mis_wu
 * @date 2022/1/1 19:15
 * 静态资源配置类
 */
@Configuration
//nacos修改文件自动刷新(放在需要自动刷新的类上)
@RefreshScope
public class StaticConfig implements WebMvcConfigurer{

    @Value("${imgFilePath}")
    private String imgFilePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //虚拟映射
        registry.addResourceHandler("/static/**")
                .addResourceLocations("file:"+imgFilePath);
    }
}
